﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterAdmin.master" AutoEventWireup="true" CodeBehind="Withdraw.aspx.cs" Inherits="UdrinkWater_Project.Admin.Withdraw" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
     <script type="text/javascript">
    // <![CDATA[
         function ShowLoginWindow() {
             pc_Withdraw.Show();
         }
    // ]]> 
    </script>
    <dx:ASPxRoundPanel ID="ASPxRoundPanel1" runat="server" 
        HeaderText="เบิกจ่ายล่วงหน้า" Width="100%">
        <HeaderStyle Font-Size="Medium" HorizontalAlign="Left" />
        <PanelCollection>
            <dx:PanelContent runat="server" SupportsDisabledAttribute="True">
                <dx:ASPxButton ID="bt_AddWithdraw" runat="server" Text="เพิ่มรายการ">
                    <ClientSideEvents Click="function(s, e) { ShowLoginWindow(); }" />
                </dx:ASPxButton>
                <dx:ASPxGridView ID="GV_ShowWithdraw" runat="server" 
                    AutoGenerateColumns="False" DataSourceID="SqlData_Withdraw" 
                    KeyFieldName="WithDraw_date" 
                    Width="100%" EnableRowsCache="False">
                    <Columns>
                        <dx:GridViewCommandColumn ShowInCustomizationForm="True" VisibleIndex="5" 
                            Caption="รายละเอียด" Width="150px">
                            <EditButton Visible="True" Text="แก้ไขรายการ">
                            </EditButton>
                            <DeleteButton Visible="True" Text="ลบรายการ">
                            </DeleteButton>
                        </dx:GridViewCommandColumn>
                        <dx:GridViewDataTextColumn FieldName="WithDraw_date" 
                            ShowInCustomizationForm="True" VisibleIndex="0" ReadOnly="True" 
                            Visible="False">
                        </dx:GridViewDataTextColumn>
                        <dx:GridViewDataDateColumn FieldName="Date_WithDraw" 
                            ShowInCustomizationForm="True" VisibleIndex="1" Caption="วันที่">
                            <PropertiesDateEdit DisplayFormatString="dd MMMM yyyy">
                            </PropertiesDateEdit>
                        </dx:GridViewDataDateColumn>
                        <dx:GridViewDataComboBoxColumn Caption="รหัสพนักงาน" FieldName="Employee_ID" 
                            ShowInCustomizationForm="True" VisibleIndex="2">
                            <PropertiesComboBox DataSourceID="SqlData_Employee" EnableCallbackMode="True" 
                                ValueField="ID_Card">
                                <Columns>
                                    <dx:ListBoxColumn Caption="รหัสพนักงาน" FieldName="ID_Card" />
                                    <dx:ListBoxColumn Caption="ชื่อ" FieldName="Firstname" />
                                </Columns>
                            </PropertiesComboBox>
                        </dx:GridViewDataComboBoxColumn>
                        <dx:GridViewDataTextColumn FieldName="Num_WithDraw" 
                            ShowInCustomizationForm="True" VisibleIndex="3" Caption="จำนวนเงิน">
                            <Settings AllowAutoFilter="False" />
                        </dx:GridViewDataTextColumn>
                        <dx:GridViewDataTextColumn FieldName="Signture_Admin" 
                            ShowInCustomizationForm="True" VisibleIndex="4" Caption="ผู้ทำรายการ">
                            <Settings AllowAutoFilter="False" />
                        </dx:GridViewDataTextColumn>
                    </Columns>
                    <SettingsBehavior ConfirmDelete="True" />
                    <Settings ShowFilterRow="True" />
                    <SettingsText ConfirmDelete="ยืนยันการลบข้อมูล" />
                </dx:ASPxGridView>
                <asp:SqlDataSource ID="SqlData_Withdraw" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:DB_Udrink %>" 
                    DeleteCommand="DELETE FROM TB_WithDraw WHERE (WithDraw_date = @WithDraw_date)" 
                    SelectCommand="SELECT * FROM [TB_WithDraw]" 
                    
                    
                    UpdateCommand="UPDATE TB_WithDraw SET Employee_ID = @Employee_ID , Num_WithDraw = @Num_WithDraw , Signture_Admin = @Signture_Admin , Date_WithDraw = @Date_WithDraw WHERE (WithDraw_date = @WithDraw_date)">
                    <DeleteParameters>
                        <asp:Parameter Name="WithDraw_date" />
                    </DeleteParameters>
                    <UpdateParameters>
                        <asp:Parameter Name="Employee_ID" />
                        <asp:Parameter Name="Num_WithDraw" />
                        <asp:Parameter Name="Signture_Admin" />
                        <asp:Parameter Name="Date_WithDraw" />
                        <asp:Parameter Name="WithDraw_date" />
                    </UpdateParameters>
                </asp:SqlDataSource>
                <asp:SqlDataSource ID="SqlData_Employee" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:DB_Udrink %>" 
                    SelectCommand="SELECT [ID_Card], [Firstname] FROM [TB_Employee]">
                </asp:SqlDataSource>
            </dx:PanelContent>
        </PanelCollection>
    </dx:ASPxRoundPanel>
    <dx:ASPxPopupControl ID="pc_Withdraw" runat="server" CloseAction="CloseButton" Modal="True"
        PopupHorizontalAlign="WindowCenter" PopupVerticalAlign="WindowCenter" ClientInstanceName="pc_Withdraw"
        HeaderText="ทำรายการเบิกล่วงหน้า" AllowDragging="True" 
         PopupAnimationType="None" EnableViewState="False" Width="379px" 
         Font-Size="Medium">
        <ClientSideEvents PopUp="function(s, e) { ASPxClientEdit.ClearGroup('entryGroup'); tbLogin.Focus(); }" />
        <ContentCollection>
            <dx:PopupControlContentControl ID="PopupControlContentControl1" runat="server">
                <dx:ASPxPanel ID="Panel1" runat="server" DefaultButton="btOK">
                    <PanelCollection>
                        <dx:PanelContent ID="PanelContent1" runat="server">
                            <table>
                                <tr>
                                    <td rowspan="5">
                                        <div class="pcmSideSpacer">
                                        </div>
                                    </td>
                                    <td class="pcmCellCaption" align="right" style="font-size: medium">
                                        วันที่ทำรายการ :</td>
                                    <td class="pcmCellText">
                                        <dx:ASPxDateEdit ID="DateEdit_Withdraw" runat="server">
                                        </dx:ASPxDateEdit>
                                    </td>
                                    <td rowspan="5">
                                        <div class="pcmSideSpacer">
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="pcmCellCaption" align="right" style="font-size: medium" >
                                        พนักงาน :</td>
                                    <td class="pcmCellText">
                                        <dx:ASPxComboBox ID="Cb_Emp" runat="server" DataSourceID="SqlData_Emp" 
                                            EnableCallbackMode="True" TextFormatString="{0}" ValueField="ID_Card">
                                            <Columns>
                                                <dx:ListBoxColumn Caption="รหัสพนักงาน" FieldName="ID_Card" />
                                                <dx:ListBoxColumn Caption="ชื่อ" FieldName="Firstname" />
                                            </Columns>
                                        </dx:ASPxComboBox>
                                        <asp:SqlDataSource ID="SqlData_Emp" runat="server" 
                                            ConnectionString="<%$ ConnectionStrings:DB_Udrink %>" 
                                            SelectCommand="SELECT [ID_Card], [Firstname] FROM [TB_Employee]">
                                        </asp:SqlDataSource>
                                    </td>
                                </tr>
                                <tr>
                                    <td align="right" class="pcmCellCaption" style="font-size: medium">
                                        จำนวน :</td>
                                    <td class="pcmCellText">
                                        <dx:ASPxTextBox ID="tbNum" runat="server" Width="150px">
                                            <ValidationSettings EnableCustomValidation="True" ErrorDisplayMode="Text" 
                                                ErrorTextPosition="Bottom" SetFocusOnError="True" ValidationGroup="entryGroup">
                                                <ErrorFrameStyle Font-Size="10px">
                                                    <ErrorTextPaddings PaddingLeft="0px" />
                                                </ErrorFrameStyle>
                                                <RequiredField ErrorText="Password required" IsRequired="True" />
                                            </ValidationSettings>
                                        </dx:ASPxTextBox>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                    </td>
                                    <td class="pcmCheckBox">
                                        <table style="width: 100%">
                                            <tr>
                                                <td>
                                                    <dx:ASPxButton ID="btOK" runat="server" AutoPostBack="False" Font-Size="Medium" 
                                                        style="float: left; margin-right: 8px" Text="ตกลง" Width="80px" 
                                                        OnClick="btOK_Click">
                                                        <ClientSideEvents Click="function(s, e) { if(ASPxClientEdit.ValidateGroup('entryGroup')) pc_Withdraw.Hide(); }" />
                                                    </dx:ASPxButton>
                                                </td>
                                                <td>
                                                    <dx:ASPxButton ID="btCancel" runat="server" AutoPostBack="False" 
                                                        Font-Size="Medium" style="float: left; margin-right: 8px" Text="ยกเลิก" 
                                                        Width="80px">
                                                        <ClientSideEvents Click="function(s, e) { pc_Withdraw.Hide(); }" />
                                                    </dx:ASPxButton>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="2">
                                        <div class="pcmButton">
                                        </div>
                                    </td>
                                </tr>
                            </table>
                        </dx:PanelContent>
                    </PanelCollection>
                </dx:ASPxPanel>
                <div>
                    &nbsp;</div>
            </dx:PopupControlContentControl>
        </ContentCollection>
        <ContentStyle>
            <Paddings PaddingBottom="5px" />
        </ContentStyle>
    </dx:ASPxPopupControl>
</asp:Content>
